package com.labmi.experiment.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.labmi.experiment.business.ClothingItem;
import com.labmi.experiment.business.Item;

public class MockItemDAO implements ItemDAO<Item> {

	/**
	 * Simulate Database
	 */
	private List<Item> itemsRepository = new ArrayList<Item>(); 
	
	private static long idGenerator = 0;
	
	public MockItemDAO() {
		if(itemsRepository.isEmpty())
			populateWithData();
	}
	
	private void populateWithData() {
		
		Item i1 =  new ClothingItem(generateID(), "Cappotto", "Lorem ipsum dolor sit amet", 	200, "css/images/big1.jpg", "L", "UOMO");
		Item i2 =  new ClothingItem(generateID(), "Cappotto", "Lorem ipsum dolor sit amet", 	170, "css/images/big1.jpg", "XL", "UOMO");
		Item i3 = new ClothingItem(generateID(), "Cappotto", "Lorem ipsum dolor sit amet", 	130, "css/images/big1.jpg", "M", "UOMO");
		Item i4 = new ClothingItem(generateID(), "Cappotto", "Lorem ipsum dolor sit amet", 	150, "css/images/big1.jpg", "S", "UOMO");
		Item i5 = new ClothingItem(generateID(), "Maglione", "Lorem ipsum dolor sit amet", 	70, "css/images/big1.jpg", "L", "UOMO");
		Item i6 = new ClothingItem(generateID(), "Maglione", "Lorem ipsum dolor sit amet", 	80, "css/images/big1.jpg", "L", "UOMO");
		Item i7 = new ClothingItem(generateID(), "Camicia", "Lorem ipsum dolor sit amet", 		50, "css/images/big1.jpg", "L", "UOMO");
		Item i8 = new ClothingItem(generateID(), "Camicia", "Lorem ipsum dolor sit amet", 		50, "css/images/big1.jpg", "XL", "UOMO");
		Item i9 = new ClothingItem(generateID(), "Pantaloni", "Lorem ipsum dolor sit amet", 	200, "css/images/big1.jpg", "L", "UOMO");
		Item i10 = new ClothingItem(generateID(), "Pantaloni", "Lorem ipsum dolor sit amet", 	200, "css/images/big1.jpg", "L", "UOMO");
		Item i11 = new ClothingItem(generateID(), "Pantaloni", "Lorem ipsum dolor sit amet", 	200, "css/images/big1.jpg", "L", "UOMO");
		Item i12 = new ClothingItem(generateID(), "Giacca", "Lorem ipsum dolor sit amet", 		100, "css/images/big1.jpg", "L", "UOMO");
		
		insertItem(i1);
		insertItem(i2);
		insertItem(i3);
		insertItem(i4);
		insertItem(i5);
		insertItem(i6);
		insertItem(i7);
		insertItem(i8);
		insertItem(i9);
		insertItem(i10);
		insertItem(i11);
		insertItem(i12);
		
	}

	@Override
	public Item getItemByID(String id) {
		
		return null;
	}

	@Override
	public List<Item> getItemListByName(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Item> getAllItems(int limit) {
		
		return itemsRepository;
	}
	
	@Override
	public Long insertItem(Item o) {
		
		idGenerator++;
		
		itemsRepository.add(o);
		
		return idGenerator;
	}

	@Override
	public Long generateID() {
		
		idGenerator++;
		return idGenerator;
	}
	
	
	@Override
	public Item updateItemById(String id) {
		// TODO Auto-generated method stub
		return null;
	}

}
